﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="CmdTool" nillable="true" type="CmdToolConfig" />
  <xs:complexType name="CmdToolConfig">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="match" type="FileMatch" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="FileMatch">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="applies-to" type="MatchAppliesTo" />
      <xs:element minOccurs="1" maxOccurs="unbounded" name="generator" type="GeneratorConfig" />
    </xs:sequence>
    <xs:attribute name="filespec" type="FileMatchPattern" use="required" />
  </xs:complexType>
  <xs:complexType name="MatchAppliesTo">
    <xs:attribute name="folder" type="FilePathPattern" use="required"/>
  </xs:complexType>
  <xs:complexType name="GeneratorConfig">
    <xs:sequence>
      <xs:choice minOccurs="1" maxOccurs="1">
        <xs:element minOccurs="1" maxOccurs="1" name="script" type="GeneratorScript" />
        <xs:element minOccurs="1" maxOccurs="1" name="execute" type="GeneratorExec" />
      </xs:choice>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="arg" type="GeneratorArgument" />
      <xs:element minOccurs="0" maxOccurs="1" name="std-input" type="GeneratorInput" />
      <xs:element minOccurs="0" maxOccurs="1" name="std-output" type="GeneratorOutput" />
      <xs:element minOccurs="0" maxOccurs="unbounded" name="output" type="GeneratorOutput" />
    </xs:sequence>
    <xs:attribute name="debug" type="xs:boolean" default="false" use="optional" />
  </xs:complexType>
  <xs:complexType name="GeneratorScript">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="type" type="GeneratorScriptType" use="required"/>
        <xs:attribute name="src" type="FilePathPattern" use="optional"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="GeneratorExec">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="exe" type="FilePathPattern" use="required"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="GeneratorArgument">
    <xs:attribute name="value" type="xs:string" use="required" />
  </xs:complexType>
  <xs:complexType name="GeneratorInput">
    <xs:attribute name="redirect" type="xs:boolean" use="required" />
  </xs:complexType>
  <xs:complexType name="GeneratorOutput">
    <xs:attribute name="extension" type="xs:string" use="required" />
  </xs:complexType>
  <xs:simpleType name="FilePathPattern">
    <xs:restriction base="xs:string">
      <xs:pattern value="^[^*?&quot;|&lt;&gt;]+$" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="FileMatchPattern">
    <xs:restriction base="xs:string">
      <xs:pattern value="^[^\\/:&quot;|&lt;&gt;]+$" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="FileExtensionPattern">
    <xs:restriction base="xs:string">
      <xs:pattern value="^.[^\\/:*?&quot;|&lt;&gt;]*$" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="GeneratorScriptType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="JScript"/>
      <xs:enumeration value="VBScript"/>
      <xs:enumeration value="Cmd"/>
      <xs:enumeration value="PowerShell"/>
      <xs:enumeration value="CSharp"/>
      <xs:enumeration value="VBNet"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>